package com.gewu.pm.ui.adapter.customer;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gewu.pm.R;
import com.gewu.pm.app.AppAdapter;

/**
 * 业务员详情 - 拜访记录列表适配器
 */
public class SalespersonVisitAdapter extends AppAdapter<String> {

    public SalespersonVisitAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new VisitViewHolder();
    }

    private final class VisitViewHolder extends AppAdapter<?>.ViewHolder {

        private final TextView mVisitDateView;
        private final TextView mVisitorView;
        private final TextView mVisitLocationView;
        private final TextView mVisitPurposeView;
        private final TextView mVisitSummaryView;
        private final TextView mArrivalTimeView;
        private final TextView mEndTimeView;

        private VisitViewHolder() {
            super(R.layout.salesperson_visit_item);
            mVisitDateView = findViewById(R.id.tv_visit_date);
            mVisitorView = findViewById(R.id.tv_visitor);
            mVisitLocationView = findViewById(R.id.tv_visit_location);
            mVisitPurposeView = findViewById(R.id.tv_visit_purpose);
            mVisitSummaryView = findViewById(R.id.tv_visit_summary);
            mArrivalTimeView = findViewById(R.id.tv_arrival_time);
            mEndTimeView = findViewById(R.id.tv_end_time);
        }

        @Override
        public void onBindView(int position) {
            String visitDate = getItem(position);
            
            // 设置拜访日期
            mVisitDateView.setText(visitDate);
            
            // TODO: 后期使用完整Bean对象替换
            // 当前显示测试数据
            mVisitorView.setText("拜访人：震辉");
            mVisitLocationView.setText("落落超市");
            mVisitPurposeView.setText("客户拜访");
            mVisitSummaryView.setText("希望增加更多口味（如五香豆腐）");
            mArrivalTimeView.setText("11:34");
            mEndTimeView.setText("11:34");
        }
    }
}

